package com.org.csu.dao;

import com.org.csu.entity.Keyword;
import com.org.csu.entity.UserRecord;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author YigongLily
 * @version V1.0
 * Copyright (c) 2024, t8669@qq.com All Rights Reserved.
 * @ProjectName:e-commerce-back
 * @Title: UserRecordRepository
 * @Package com.org.csu.dao
 * @Description: userrecordRe
 * @date 2024/12/15 20:59
 */
@Repository
public interface UserRecordRepository extends JpaRepository<UserRecord, Integer> {
    //插入一条用户搜索记录(提供)

    //根据日期userId和关键词查询某一条记录
    @Query("SELECT ur FROM UserRecord ur WHERE ur.date = :date AND ur.userId = :userId AND ur.keyword = :keyword")
    UserRecord findByDateAndUserIdAndKeyword(String date, Integer userId, String keyword);

    //根据用户id查询用户搜索记录
    List<UserRecord> findByUserId(Integer userId);

}